package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.TreeNode;

/**
 * 104. 二叉树的最大深度
 * 
 * https://leetcode.cn/problems/maximum-depth-of-binary-tree/
 * 
 * @author jie.deng
 *
 */
class Question0104Solution01 {
	
	public int maxDepth(TreeNode root) {
		// 递归：自底向上
		if (root == null) {
			return 0;
		}
		int depthLeft = maxDepth(root.left);
		int depthRight = maxDepth(root.right);
		return 1 + Math.max(depthLeft, depthRight);
	}
    
}